home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / c / wait.c < prev   
C/C++ Source or Header  |  1996-09-13  |  1KB  |  70 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: wait.c,v 1.4 1996/09/13 17:52:12 digulla Exp $
  4.     $Log: wait.c,v $
  5.     Revision 1.4  1996/09/13 17:52:12  digulla
  6.     Use IPTR
  7.  
  8.     Revision 1.3  1996/08/13 15:34:04  digulla
  9.     #include <exec/execbase.h> was missing
  10.  
  11.     Revision 1.2  1996/08/01 17:40:46  digulla
  12.     Added standard header for all files
  13.  
  14.     Desc:
  15.     Lang:
  16. */
  17. #include <exec/execbase.h>
  18. #include <exec/libraries.h>
  19. #include <clib/exec_protos.h>
  20. #include <dos/dos.h>
  21. #include <clib/dos_protos.h>
  22.  
  23. CALLENTRY /* Before the first symbol */
  24.  
  25. struct ExecBase *SysBase;
  26. struct DosLibrary *DOSBase;
  27.  
  28. static LONG tinymain(void);
  29.  
  30. LONG entry(struct ExecBase *sysbase)
  31. {
  32.     LONG error=RETURN_FAIL;
  33.     SysBase=sysbase;
  34.     DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",39);
  35.     if(DOSBase!=NULL)
  36.     {
  37.     error=tinymain();
  38.     CloseLibrary((struct Library *)DOSBase);
  39.     }
  40.     return error;
  41. }
  42.  
  43. static LONG tinymain(void)
  44. {
  45.     IPTR args[4]={ 0, 0, 0, 0 };
  46.     struct RDArgs *rda;
  47.     LONG error=0;
  48.     ULONG delay = 1;
  49. #define ERROR(a) { error=a; goto end; }
  50.  
  51.     rda=ReadArgs("time/N,SEC=SECS/S,MIN=MINS/S,UNTIL/K",args,NULL);
  52.     if(rda==NULL)
  53.     ERROR(RETURN_FAIL);
  54.  
  55.     if (args[0])
  56.     delay = *((ULONG *)args[0]);
  57.  
  58.     if (args[2])
  59.     delay *= 60L;
  60.  
  61.     if (delay > 0)
  62.     Delay (delay * 50L);
  63.  
  64. end:
  65.     FreeArgs(rda);
  66.     if(error)
  67.     PrintFault(IoErr(),"Echo");
  68.     return error;
  69. }
  70.